<?php
header("Content-type: text/html; charset=utf-8");
require_once "mysql_connect.php"; //connect

$id = $_GET['id'];



$filename = 'spell.txt';

$exec = "SELECT * from db_wow_spell ORDER BY id LIMIT $id,1000";

$result=MySQL_query($exec);
//$s=MySQL_fetch_object($result);

$fh = fopen($filename, "a");
$words = "";
    while($rs=MySQL_fetch_object($result)){//sql result
		if($rs->name){
			$words .= $rs->name."|spell?id=".$rs->id."\n";	
		}
	}

echo fwrite($fh, $words); 
fclose($fh);

if ($id >= '57369'){
	echo "<script>alert('全部完成！')</script>";
}else{
	$id = $id + 1000;
	echo "<script>location.href='spell_r.php?id=$id'</script>";
}
?>